<template>
  <el-select class="w100" filterable clearable placeholder="请选择" v-bind="$attrs">
    <el-option v-for="item in users" :key="item.id" :label="item.name" :value="item.id"></el-option>
  </el-select>
</template>

<script lang="ts" setup name="userSelect">
import { readAllUser } from '/@/api/user';
import { ref, onMounted } from 'vue';

const props = defineProps({
  workRole: {
    type: String,
    default: undefined,
  }
});
const users = ref();

const getUserList = async () => {
  const { data } = await readAllUser({ work_role: props.workRole });
  users.value = data.list;
};

onMounted(() => {
  getUserList();
});
</script>
